home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / CIncludes / SpeechSynthesis.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-12  |  12.8 KB  |  394 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        SpeechSynthesis.h
  3.  
  4.      Contains:    Speech Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0.1
  8.  
  9.      Copyright:    © 1989-1997 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __SPEECHSYNTHESIS__
  19. #define __SPEECHSYNTHESIS__
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. #ifndef __MIXEDMODE__
  25. #include <MixedMode.h>
  26. #endif
  27. #ifndef __FILES__
  28. #include <Files.h>
  29. #endif
  30.  
  31.  
  32.  
  33. #if PRAGMA_ONCE
  34. #pragma once
  35. #endif
  36.  
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40.  
  41. #if PRAGMA_IMPORT
  42. #pragma import on
  43. #endif
  44.  
  45. #if PRAGMA_STRUCT_ALIGN
  46.     #pragma options align=mac68k
  47. #elif PRAGMA_STRUCT_PACKPUSH
  48.     #pragma pack(push, 2)
  49. #elif PRAGMA_STRUCT_PACK
  50.     #pragma pack(2)
  51. #endif
  52.  
  53.  
  54. enum {
  55.     kTextToSpeechSynthType        = FOUR_CHAR_CODE('ttsc'),
  56.     kTextToSpeechVoiceType        = FOUR_CHAR_CODE('ttvd'),
  57.     kTextToSpeechVoiceFileType    = FOUR_CHAR_CODE('ttvf'),
  58.     kTextToSpeechVoiceBundleType = FOUR_CHAR_CODE('ttvb')
  59. };
  60.  
  61.  
  62. enum {
  63.     kNoEndingProsody            = 1,
  64.     kNoSpeechInterrupt            = 2,
  65.     kPreflightThenPause            = 4
  66. };
  67.  
  68.  
  69. enum {
  70.     kImmediate                    = 0,
  71.     kEndOfWord                    = 1,
  72.     kEndOfSentence                = 2
  73. };
  74.  
  75.  
  76. /*------------------------------------------*/
  77. /* GetSpeechInfo & SetSpeechInfo selectors    */
  78. /*------------------------------------------*/
  79.  
  80. enum {
  81.     soStatus                    = FOUR_CHAR_CODE('stat'),
  82.     soErrors                    = FOUR_CHAR_CODE('erro'),
  83.     soInputMode                    = FOUR_CHAR_CODE('inpt'),
  84.     soCharacterMode                = FOUR_CHAR_CODE('char'),
  85.     soNumberMode                = FOUR_CHAR_CODE('nmbr'),
  86.     soRate                        = FOUR_CHAR_CODE('rate'),
  87.     soPitchBase                    = FOUR_CHAR_CODE('pbas'),
  88.     soPitchMod                    = FOUR_CHAR_CODE('pmod'),
  89.     soVolume                    = FOUR_CHAR_CODE('volm'),
  90.     soSynthType                    = FOUR_CHAR_CODE('vers'),
  91.     soRecentSync                = FOUR_CHAR_CODE('sync'),
  92.     soPhonemeSymbols            = FOUR_CHAR_CODE('phsy'),
  93.     soCurrentVoice                = FOUR_CHAR_CODE('cvox'),
  94.     soCommandDelimiter            = FOUR_CHAR_CODE('dlim'),
  95.     soReset                        = FOUR_CHAR_CODE('rset'),
  96.     soCurrentA5                    = FOUR_CHAR_CODE('myA5'),
  97.     soRefCon                    = FOUR_CHAR_CODE('refc'),
  98.     soTextDoneCallBack            = FOUR_CHAR_CODE('tdcb'),        /* use with SpeechTextDoneProcPtr*/
  99.     soSpeechDoneCallBack        = FOUR_CHAR_CODE('sdcb'),        /* use with SpeechDoneProcPtr*/
  100.     soSyncCallBack                = FOUR_CHAR_CODE('sycb'),        /* use with SpeechSyncProcPtr*/
  101.     soErrorCallBack                = FOUR_CHAR_CODE('ercb'),        /* use with SpeechErrorProcPtr*/
  102.     soPhonemeCallBack            = FOUR_CHAR_CODE('phcb'),        /* use with SpeechPhonemeProcPtr*/
  103.     soWordCallBack                = FOUR_CHAR_CODE('wdcb'),
  104.     soSynthExtension            = FOUR_CHAR_CODE('xtnd'),
  105.     soSoundOutput                = FOUR_CHAR_CODE('sndo')
  106. };
  107.  
  108.  
  109. /*------------------------------------------*/
  110. /* Speaking Mode Constants                     */
  111. /*------------------------------------------*/
  112.  
  113. enum {
  114.     modeText                    = FOUR_CHAR_CODE('TEXT'),        /* input mode constants                     */
  115.     modePhonemes                = FOUR_CHAR_CODE('PHON'),
  116.     modeNormal                    = FOUR_CHAR_CODE('NORM'),        /* character mode and number mode constants */
  117.     modeLiteral                    = FOUR_CHAR_CODE('LTRL')
  118. };
  119.  
  120.  
  121.  
  122. enum {
  123.     soVoiceDescription            = FOUR_CHAR_CODE('info'),
  124.     soVoiceFile                    = FOUR_CHAR_CODE('fref')
  125. };
  126.  
  127.  
  128. struct SpeechChannelRecord {
  129.     long                             data[1];
  130. };
  131. typedef struct SpeechChannelRecord SpeechChannelRecord;
  132.  
  133. typedef SpeechChannelRecord *            SpeechChannel;
  134.  
  135. struct VoiceSpec {
  136.     OSType                             creator;
  137.     OSType                             id;
  138. };
  139. typedef struct VoiceSpec VoiceSpec;
  140.  
  141. typedef VoiceSpec *                        VoiceSpecPtr;
  142.  
  143.  
  144. enum {
  145.     kNeuter                        = 0,
  146.     kMale                        = 1,
  147.     kFemale                        = 2
  148. };
  149.  
  150.  
  151.  
  152.  
  153. struct VoiceDescription {
  154.     long                             length;
  155.     VoiceSpec                         voice;
  156.     long                             version;
  157.     Str63                             name;
  158.     Str255                             comment;
  159.     short                             gender;
  160.     short                             age;
  161.     short                             script;
  162.     short                             language;
  163.     short                             region;
  164.     long                             reserved[4];
  165. };
  166. typedef struct VoiceDescription VoiceDescription;
  167.  
  168.  
  169.  
  170. struct VoiceFileInfo {
  171.     FSSpec                             fileSpec;
  172.     short                             resID;
  173. };
  174. typedef struct VoiceFileInfo VoiceFileInfo;
  175.  
  176. struct SpeechStatusInfo {
  177.     Boolean                         outputBusy;
  178.     Boolean                         outputPaused;
  179.     long                             inputBytesLeft;
  180.     short                             phonemeCode;
  181. };
  182. typedef struct SpeechStatusInfo SpeechStatusInfo;
  183.  
  184.  
  185.  
  186. struct SpeechErrorInfo {
  187.     short                             count;
  188.     OSErr                             oldest;
  189.     long                             oldPos;
  190.     OSErr                             newest;
  191.     long                             newPos;
  192. };
  193. typedef struct SpeechErrorInfo SpeechErrorInfo;
  194.  
  195.  
  196.  
  197. struct SpeechVersionInfo {
  198.     OSType                             synthType;
  199.     OSType                             synthSubType;
  200.     OSType                             synthManufacturer;
  201.     long                             synthFlags;
  202.     NumVersion                         synthVersion;
  203. };
  204. typedef struct SpeechVersionInfo SpeechVersionInfo;
  205.  
  206.  
  207.  
  208. struct PhonemeInfo {
  209.     short                             opcode;
  210.     Str15                             phStr;
  211.     Str31                             exampleStr;
  212.     short                             hiliteStart;
  213.     short                             hiliteEnd;
  214. };
  215. typedef struct PhonemeInfo PhonemeInfo;
  216.  
  217.  
  218. struct PhonemeDescriptor {
  219.     short                             phonemeCount;
  220.     PhonemeInfo                     thePhonemes[1];
  221. };
  222. typedef struct PhonemeDescriptor PhonemeDescriptor;
  223.  
  224. struct SpeechXtndData {
  225.     OSType                             synthCreator;
  226.     Byte                             synthData[2];
  227. };
  228. typedef struct SpeechXtndData SpeechXtndData;
  229.  
  230.  
  231. struct DelimiterInfo {
  232.     Byte                             startDelimiter[2];
  233.     Byte                             endDelimiter[2];
  234. };
  235. typedef struct DelimiterInfo DelimiterInfo;
  236.  
  237.  
  238. typedef CALLBACK_API( void , SpeechTextDoneProcPtr )(SpeechChannel chan, long refCon, const void **nextBuf, unsigned long *byteLen, long *controlFlags);
  239. typedef CALLBACK_API( void , SpeechDoneProcPtr )(SpeechChannel chan, long refCon);
  240. typedef CALLBACK_API( void , SpeechSyncProcPtr )(SpeechChannel chan, long refCon, OSType syncMessage);
  241. typedef CALLBACK_API( void , SpeechErrorProcPtr )(SpeechChannel chan, long refCon, OSErr theError, long bytePos);
  242. typedef CALLBACK_API( void , SpeechPhonemeProcPtr )(SpeechChannel chan, long refCon, short phonemeOpcode);
  243. typedef CALLBACK_API( void , SpeechWordProcPtr )(SpeechChannel chan, long refCon, unsigned long wordPos, unsigned short wordLen);
  244. typedef STACK_UPP_TYPE(SpeechTextDoneProcPtr)                     SpeechTextDoneUPP;
  245. typedef STACK_UPP_TYPE(SpeechDoneProcPtr)                         SpeechDoneUPP;
  246. typedef STACK_UPP_TYPE(SpeechSyncProcPtr)                         SpeechSyncUPP;
  247. typedef STACK_UPP_TYPE(SpeechErrorProcPtr)                         SpeechErrorUPP;
  248. typedef STACK_UPP_TYPE(SpeechPhonemeProcPtr)                     SpeechPhonemeUPP;
  249. typedef STACK_UPP_TYPE(SpeechWordProcPtr)                         SpeechWordUPP;
  250. enum { uppSpeechTextDoneProcInfo = 0x0000FFC0 };                 /* pascal no_return_value Func(4_bytes, 4_bytes, 4_bytes, 4_bytes, 4_bytes) */
  251. enum { uppSpeechDoneProcInfo = 0x000003C0 };                     /* pascal no_return_value Func(4_bytes, 4_bytes) */
  252. enum { uppSpeechSyncProcInfo = 0x00000FC0 };                     /* pascal no_return_value Func(4_bytes, 4_bytes, 4_bytes) */
  253. enum { uppSpeechErrorProcInfo = 0x00003BC0 };                     /* pascal no_return_value Func(4_bytes, 4_bytes, 2_bytes, 4_bytes) */
  254. enum { uppSpeechPhonemeProcInfo = 0x00000BC0 };                 /* pascal no_return_value Func(4_bytes, 4_bytes, 2_bytes) */
  255. enum { uppSpeechWordProcInfo = 0x00002FC0 };                     /* pascal no_return_value Func(4_bytes, 4_bytes, 4_bytes, 2_bytes) */
  256. #define NewSpeechTextDoneProc(userRoutine)                         (SpeechTextDoneUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechTextDoneProcInfo, GetCurrentArchitecture())
  257. #define NewSpeechDoneProc(userRoutine)                             (SpeechDoneUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechDoneProcInfo, GetCurrentArchitecture())
  258. #define NewSpeechSyncProc(userRoutine)                             (SpeechSyncUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechSyncProcInfo, GetCurrentArchitecture())
  259. #define NewSpeechErrorProc(userRoutine)                         (SpeechErrorUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechErrorProcInfo, GetCurrentArchitecture())
  260. #define NewSpeechPhonemeProc(userRoutine)                         (SpeechPhonemeUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechPhonemeProcInfo, GetCurrentArchitecture())
  261. #define NewSpeechWordProc(userRoutine)                             (SpeechWordUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSpeechWordProcInfo, GetCurrentArchitecture())
  262. #define CallSpeechTextDoneProc(userRoutine, chan, refCon, nextBuf, byteLen, controlFlags)  CALL_FIVE_PARAMETER_UPP((userRoutine), uppSpeechTextDoneProcInfo, (chan), (refCon), (nextBuf), (byteLen), (controlFlags))
  263. #define CallSpeechDoneProc(userRoutine, chan, refCon)             CALL_TWO_PARAMETER_UPP((userRoutine), uppSpeechDoneProcInfo, (chan), (refCon))
  264. #define CallSpeechSyncProc(userRoutine, chan, refCon, syncMessage)  CALL_THREE_PARAMETER_UPP((userRoutine), uppSpeechSyncProcInfo, (chan), (refCon), (syncMessage))
  265. #define CallSpeechErrorProc(userRoutine, chan, refCon, theError, bytePos)  CALL_FOUR_PARAMETER_UPP((userRoutine), uppSpeechErrorProcInfo, (chan), (refCon), (theError), (bytePos))
  266. #define CallSpeechPhonemeProc(userRoutine, chan, refCon, phonemeOpcode)  CALL_THREE_PARAMETER_UPP((userRoutine), uppSpeechPhonemeProcInfo, (chan), (refCon), (phonemeOpcode))
  267. #define CallSpeechWordProc(userRoutine, chan, refCon, wordPos, wordLen)  CALL_FOUR_PARAMETER_UPP((userRoutine), uppSpeechWordProcInfo, (chan), (refCon), (wordPos), (wordLen))
  268. EXTERN_API( NumVersion )
  269. SpeechManagerVersion            (void)                                                        FOURWORDINLINE(0x203C, 0x0000, 0x000C, 0xA800);
  270.  
  271. EXTERN_API( OSErr )
  272. MakeVoiceSpec                    (OSType                 creator,
  273.                                  OSType                 id,
  274.                                  VoiceSpec *            voice)                                FOURWORDINLINE(0x203C, 0x0604, 0x000C, 0xA800);
  275.  
  276. EXTERN_API( OSErr )
  277. CountVoices                        (short *                numVoices)                            FOURWORDINLINE(0x203C, 0x0108, 0x000C, 0xA800);
  278.  
  279. EXTERN_API( OSErr )
  280. GetIndVoice                        (short                     index,
  281.                                  VoiceSpec *            voice)                                FOURWORDINLINE(0x203C, 0x030C, 0x000C, 0xA800);
  282.  
  283. EXTERN_API( OSErr )
  284. GetVoiceDescription                (const VoiceSpec *        voice,
  285.                                  VoiceDescription *        info,
  286.                                  long                     infoLength)                            FOURWORDINLINE(0x203C, 0x0610, 0x000C, 0xA800);
  287.  
  288. EXTERN_API( OSErr )
  289. GetVoiceInfo                    (const VoiceSpec *        voice,
  290.                                  OSType                 selector,
  291.                                  void *                    voiceInfo)                            FOURWORDINLINE(0x203C, 0x0614, 0x000C, 0xA800);
  292.  
  293. EXTERN_API( OSErr )
  294. NewSpeechChannel                (VoiceSpecPtr             voice,
  295.                                  SpeechChannel *        chan)                                FOURWORDINLINE(0x203C, 0x0418, 0x000C, 0xA800);
  296.  
  297. EXTERN_API( OSErr )
  298. DisposeSpeechChannel            (SpeechChannel             chan)                                FOURWORDINLINE(0x203C, 0x021C, 0x000C, 0xA800);
  299.  
  300. EXTERN_API( OSErr )
  301. SpeakString                        (ConstStr255Param         textToBeSpoken)                        FOURWORDINLINE(0x203C, 0x0220, 0x000C, 0xA800);
  302.  
  303. EXTERN_API( OSErr )
  304. SpeakText                        (SpeechChannel             chan,
  305.                                  const void *            textBuf,
  306.                                  unsigned long             textBytes)                            FOURWORDINLINE(0x203C, 0x0624, 0x000C, 0xA800);
  307.  
  308. EXTERN_API( OSErr )
  309. SpeakBuffer                        (SpeechChannel             chan,
  310.                                  const void *            textBuf,
  311.                                  unsigned long             textBytes,
  312.                                  long                     controlFlags)                        FOURWORDINLINE(0x203C, 0x0828, 0x000C, 0xA800);
  313.  
  314. EXTERN_API( OSErr )
  315. StopSpeech                        (SpeechChannel             chan)                                FOURWORDINLINE(0x203C, 0x022C, 0x000C, 0xA800);
  316.  
  317. EXTERN_API( OSErr )
  318. StopSpeechAt                    (SpeechChannel             chan,
  319.                                  long                     whereToStop)                        FOURWORDINLINE(0x203C, 0x0430, 0x000C, 0xA800);
  320.  
  321. EXTERN_API( OSErr )
  322. PauseSpeechAt                    (SpeechChannel             chan,
  323.                                  long                     whereToPause)                        FOURWORDINLINE(0x203C, 0x0434, 0x000C, 0xA800);
  324.  
  325. EXTERN_API( OSErr )
  326. ContinueSpeech                    (SpeechChannel             chan)                                FOURWORDINLINE(0x203C, 0x0238, 0x000C, 0xA800);
  327.  
  328. EXTERN_API( short )
  329. SpeechBusy                        (void)                                                        FOURWORDINLINE(0x203C, 0x003C, 0x000C, 0xA800);
  330.  
  331. EXTERN_API( short )
  332. SpeechBusySystemWide            (void)                                                        FOURWORDINLINE(0x203C, 0x0040, 0x000C, 0xA800);
  333.  
  334. EXTERN_API( OSErr )
  335. SetSpeechRate                    (SpeechChannel             chan,
  336.                                  Fixed                     rate)                                FOURWORDINLINE(0x203C, 0x0444, 0x000C, 0xA800);
  337.  
  338. EXTERN_API( OSErr )
  339. GetSpeechRate                    (SpeechChannel             chan,
  340.                                  Fixed *                rate)                                FOURWORDINLINE(0x203C, 0x0448, 0x000C, 0xA800);
  341.  
  342. EXTERN_API( OSErr )
  343. SetSpeechPitch                    (SpeechChannel             chan,
  344.                                  Fixed                     pitch)                                FOURWORDINLINE(0x203C, 0x044C, 0x000C, 0xA800);
  345.  
  346. EXTERN_API( OSErr )
  347. GetSpeechPitch                    (SpeechChannel             chan,
  348.                                  Fixed *                pitch)                                FOURWORDINLINE(0x203C, 0x0450, 0x000C, 0xA800);
  349.  
  350. EXTERN_API( OSErr )
  351. SetSpeechInfo                    (SpeechChannel             chan,
  352.                                  OSType                 selector,
  353.                                  const void *            speechInfo)                            FOURWORDINLINE(0x203C, 0x0654, 0x000C, 0xA800);
  354.  
  355. EXTERN_API( OSErr )
  356. GetSpeechInfo                    (SpeechChannel             chan,
  357.                                  OSType                 selector,
  358.                                  void *                    speechInfo)                            FOURWORDINLINE(0x203C, 0x0658, 0x000C, 0xA800);
  359.  
  360. EXTERN_API( OSErr )
  361. TextToPhonemes                    (SpeechChannel             chan,
  362.                                  const void *            textBuf,
  363.                                  unsigned long             textBytes,
  364.                                  Handle                 phonemeBuf,
  365.                                  long *                    phonemeBytes)                        FOURWORDINLINE(0x203C, 0x0A5C, 0x000C, 0xA800);
  366.  
  367. EXTERN_API( OSErr )
  368. UseDictionary                    (SpeechChannel             chan,
  369.                                  Handle                 dictionary)                            FOURWORDINLINE(0x203C, 0x0460, 0x000C, 0xA800);
  370.  
  371.  
  372.  
  373.  
  374. #if PRAGMA_STRUCT_ALIGN
  375.     #pragma options align=reset
  376. #elif PRAGMA_STRUCT_PACKPUSH
  377.     #pragma pack(pop)
  378. #elif PRAGMA_STRUCT_PACK
  379.     #pragma pack()
  380. #endif
  381.  
  382. #ifdef PRAGMA_IMPORT_OFF
  383. #pragma import off
  384. #elif PRAGMA_IMPORT
  385. #pragma import reset
  386. #endif
  387.  
  388. #ifdef __cplusplus
  389. }
  390. #endif
  391.  
  392. #endif /* __SPEECHSYNTHESIS__ */
  393.  
  394.